home *** CD-ROM | disk | FTP | other *** search
- // ============================================================================
- // TUTORIAL 1
- //
- // The script implements tutorial nr 1.
- //
- // Topic :
- // - Basic navigation
- // - Building basic production
- // ============================================================================
-
- // ============================================================================
- // VARIABLES
- // ============================================================================
-
- [VARIABLES]
-
- // Parameter variables.
- ReturnState$
- FirstTutorialTextID
- LastTutorialTextID
- TutorialTextID
-
- // Global variables.
- LastBuildingTime
- LastEvaluationTime
- Shop_X
- Shop_Y
- ShopID
- Farm_X
- Farm_Y
- FarmID
- StoragePlace_X
- StoragePlace_Y
- StoragePlaceID
-
- // Local temporary variables.
- Local_i
- Local_j
- temp
-
-
- // ============================================================================
- // INIT
- // ============================================================================
- [STATE Load]
-
- LoadGame("missions\\00_00_Tutorial 1_1900.ig2")
- LoadMissionConfig("missions\\00_00_Tutorial 1_1900.mis")
- SetOutputMode(2)
- SetMsgFilter(65535)
- StartCommandFiltering()
- ControlBar.SetDisable(871)
- DialogControl.SetDisable(22)
- SetState("Explain_Scrolling")
-
-
- // ============================================================================
- // EXPLANATION : RECALL NEWS
- // ============================================================================
- [STATE Explain_News]
- TutorialTextID = 203
- ReturnState = 'Wait_for_news_list'
- SetState("Show_tutorial_text")
-
- [STATE Wait_for_news_list]
- IF NewsDialog.IsOpen() == 1
- THEN
- SetState("Wait_for_news_close")
- END
-
- [STATE Wait_for_news_close]
- IF NewsDialog.IsOpen() == 0
- THEN
- SetState("Start_build_shop")
- END
-
-
- // ============================================================================
- // EXPLANATION : BASIC NAVIGATION
- // ============================================================================
- [STATE Explain_Scrolling]
- FirstTutorialTextID = 200
- LastTutorialTextID = 201
- ReturnState = 'Wait_Scroll'
- SetState("Show_tutorial_text_serie")
-
- [STATE Wait_Scroll]
- IF IsEnterState
- THEN
- Local_i = GetMapOriginY()
- Local_j = GetMapOriginX()
- ELSE
- IF Local_i <> GetMapOriginY() OR
- Local_j <> GetMapOriginX()
- THEN
- SetState("Wait_Not_Scroll")
- END
- END
-
- [STATE Wait_Not_Scroll]
- IF IsEnterState
- THEN
- temp = Time.ms
- Local_i = GetMapOriginY()
- Local_j = GetMapOriginX()
- ELSE
- IF Local_i <> GetMapOriginY() OR
- Local_j <> GetMapOriginX()
- THEN
- // Still scrolling ...
- Local_i = GetMapOriginY()
- Local_j = GetMapOriginX()
- temp = Time.ms
- ELSE
- IF temp + 200 < Time.ms
- THEN
- SetState("Explain_Minimap")
- END
- END
- END
-
- [STATE Explain_Zoom]
- TutorialTextID = 260
- ReturnState = 'Explain_Minimap'
- SetState("Show_tutorial_text")
-
- [STATE Explain_Minimap]
- TutorialTextID = 202
- ReturnState = 'Wait_for_Minimap'
- SetState("Show_tutorial_text")
-
- [STATE Wait_for_Minimap]
- IF IsDialogOpen("MiniMap_S_Dlg.uif") OR
- IsDialogOpen("MiniMap_L_Dlg.uif")
- THEN
- SetState("Explain_News")
- END
-
-
- // ============================================================================
- // EXPLANATION : HOW TO BUILD
- // ============================================================================
- [STATE Explain_how_to_build]
- CenterUserViewTo(68, 83)
- FirstTutorialTextID = 205
- LastTutorialTextID = 207
- ReturnState = 'Start_build_shop'
- SetState("Show_tutorial_text_serie")
-
-
- // ============================================================================
- // EXPLANATION : BUILD SHOP
- // ============================================================================
- [STATE Start_build_shop]
- CenterUserViewTo(68, 83)
- FirstTutorialTextID = 205
- LastTutorialTextID = 207
- ReturnState = 'Wait_build_menu'
- SetState("Show_tutorial_text_serie")
-
- [STATE Explain_categories]
- IF BuildDialog.IsOpen()
- THEN
- FirstTutorialTextID = 206
- LastTutorialTextID = 207
- ReturnState = 'Wait_shop_placing'
- SetState("Show_tutorial_text_serie")
- END
-
- [STATE Wait_build_menu]
-
- IF BuildDialog.IsOpen()
- THEN
- IF BuildDialog.GetPanelID() <> 3
- THEN
- FirstTutorialTextID = 208
- LastTutorialTextID = 209
- ReturnState = 'Wait_shop_panel'
- SetState("Show_tutorial_text_serie")
- ELSE
- SetState("Wait_shop_panel")
- END
- END
-
- [STATE Wait_shop_panel]
-
- IF BuildDialog.GetPanelID() == 3
- THEN
- ClearCommandQueue()
-
- FirstTutorialTextID = 210
- LastTutorialTextID = 213
- ReturnState = 'Wait_shop_placing'
- SetState("Show_tutorial_text_serie")
- ELSE
- IF BuildDialog.IsOpen() == 0
- THEN
- SetState("Start_build_shop")
- END
- END
-
- [STATE Wait_shop_selection]
-
- IF BuildDialog.GetSelectionID() == 7
- THEN
- ClearCommandQueue()
- FirstTutorialTextID = 209
- LastTutorialTextID = 211
- ReturnState = 'Wait_shop_placing'
- SetState("Show_tutorial_text_serie")
-
- ELSE
- IF BuildDialog.IsOpen() == 0
- THEN
- SetState("Start_build_shop")
- ELSE
- IF BuildDialog.GetPanelID() <> 3
- THEN
- FirstTutorialTextID = 206
- LastTutorialTextID = 207
- ReturnState = 'Wait_shop_panel'
- SetState("Show_tutorial_text_serie")
- END
- END
- END
-
- [STATE Wait_shop_placing]
-
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 8 AND
- NextCommand.GetInternType() == 7
- THEN
- SetState("Verify_shop_location")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- TutorialTextID = 207
- ReturnState = 'Wait_shop_placing'
- SetState("Show_tutorial_text")
- END
- ELSE
- // Is the build menu closed ?
- IF BuildDialog.IsOpen() == 0
- THEN
- // Ask the user to open it.
- SetState("Start_build_shop")
- ELSE
- IF BuildDialog.GetPanelID() <> 3
- THEN
- TutorialTextID = 209
- ReturnState = 'Wait_shop_panel'
- SetState("Show_tutorial_text")
- END
- END
- END
-
- [STATE Verify_shop_location]
-
- // Fetch the building coordinates.
- Shop_X = NextCommand.GetX()
- Shop_Y = NextCommand.GetY()
-
- // Is it near enough ?
- IF abs(Shop_X - 69) < 10 AND
- abs(Shop_Y - 86) < 10
- THEN
- NextCommand.Run()
- ShopID = User.GetLastBuildingBuilt()
- ClearCommandQueue()
- SetState("Start_build_storage_place")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- TutorialTextID = 104
- ReturnState = 'Wait_shop_placing'
- SetState("Show_tutorial_text")
- END
-
-
- // ============================================================================
- // EXPLANATION : BUILD STORAGE PLACE
- // ============================================================================
-
- [STATE Start_build_storage_place]
- FirstTutorialTextID = 216
- LastTutorialTextID = 218
- ReturnState = 'Wait_storage_place_placement'
- SetState("Show_tutorial_text_serie")
-
- [STATE Wait_storage_place_selection]
-
- IF BuildDialog.IsOpen() == 1
- THEN
- IF BuildDialog.GetPanelID() == 2
- THEN
- IF BuildDialog.GetSelectionID() == 1
- THEN
- ClearCommandQueue()
- TutorialTextID = 223
- ReturnState = 'Wait_storage_place_placement'
- SetState("Show_tutorial_text")
- END
- END
- END
-
- [STATE Wait_storage_place_placement]
-
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 7
- THEN
- SetState("Verify_Storage_place_location")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("Start_build_storage_place")
- END
- END
-
- [STATE Verify_Storage_place_location]
- // Check are both farm and shop highlighted
- IF IsHighlighted(ShopID)
- THEN
- NextCommand.Run()
- StoragePlaceID = User.GetLastBuildingBuilt()
- ClearCommandQueue()
- SetState("Start_build_hen_farm")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- TutorialTextID = 218
- ReturnState = 'Wait_storage_place_placement'
- SetState("Show_tutorial_text")
- END
-
-
-
- // ============================================================================
- // EXPLANATION : BUILD HEN FARM
- // ============================================================================
-
- [STATE Start_build_hen_farm]
-
- TutorialTextID = 221
- ReturnState = 'Wait_farm_selection'
- SetState("Show_tutorial_text")
-
- [STATE Wait_farm_selection]
-
- ClearCommandQueue()
-
- IF BuildDialog.IsOpen() == 1
- THEN
- IF BuildDialog.GetPanelID() == 1
- THEN
- IF BuildDialog.GetSelectionID() == 6
- THEN
- TutorialTextID = 224
- ReturnState = 'Wait_farm_placement'
- SetState("Show_tutorial_text")
- END
- END
- END
-
- [STATE Wait_farm_placement]
-
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 4
- THEN
- SetState("Verify_farm_location")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- TutorialTextID = 122
- ReturnState = 'Wait_farm_placement'
- SetState("Show_tutorial_text")
- END
- ELSE
- IF BuildDialog.IsOpen() == 0
- THEN
- SetState("Start_build_hen_farm")
- ELSE
- IF BuildDialog.GetPanelID() <> 1
- THEN
- SetState("Start_build_hen_farm")
- ELSE
- IF BuildDialog.GetSelectionID() <> 6
- THEN
- SetState("Start_build_hen_farm")
- END
- END
- END
- END
-
- [STATE Verify_farm_location]
-
- // Fetch the building coordinates.
- Farm_X = NextCommand.GetX()
- Farm_Y = NextCommand.GetY()
-
- // Is it near enough ?
- IF IsHighlighted(StoragePlaceID)
- THEN
- NextCommand.Run()
- FarmID = User.GetLastBuildingBuilt()
- ClearCommandQueue()
- SetState("Start_set_production")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- TutorialTextID = 224
- ReturnState = 'Wait_farm_placement'
- SetState("Show_tutorial_text")
- END
-
-
- // ============================================================================
- // EXPLANATION : SET PRODUCTION
- // ============================================================================
-
- [STATE Closing_build_menu]
-
- ClearCommandQueue()
- TutorialTextID = 227
- ReturnState = 'Wait_for_menu_closing'
- SetState("Show_tutorial_text")
-
- [STATE Wait_for_menu_closing]
-
- IF BuildDialog.IsOpen() == 0
- THEN
- SetState("Start_set_production")
- END
-
- [STATE Start_set_production]
- FirstTutorialTextID = 230
- LastTutorialTextID = 231
- ReturnState = 'Wait_for_production_menu'
- SetState("Show_tutorial_text_serie")
-
- [STATE Wait_for_production_menu]
-
- IF ProductionDialog.IsOpen() == 1
- THEN
- TutorialTextID = 234
- ReturnState = 'Wait_for_product_selection'
- SetState("Show_tutorial_text")
- END
-
- [STATE Wait_for_product_selection]
-
- IF ProductionDialog.GetProduct() == 18
- THEN
- TutorialTextID = 237
- ReturnState = 'Wait_for_load'
- SetState("Show_tutorial_text")
- END
-
- IF ProductionDialog.IsOpen() == 0
- THEN
- SetState("Start_set_production")
- END
-
-
- [STATE Wait_for_load]
- IF ProductionDialog.GetLoad() == 50
- THEN
- ClearCommandQueue()
- TutorialTextID = 240
- ReturnState = 'Wait_for_set_production'
- SetState("Show_tutorial_text")
- END
-
- IF ProductionDialog.IsOpen() == 0
- THEN
- SetState("Start_set_production")
- END
-
-
- [STATE Wait_for_set_production]
-
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 14
- THEN
- SetState("Verify_farm_production")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- TutorialTextID = 142
- ReturnState = 'Wait_for_production_menu'
- SetState("Show_tutorial_text")
- END
- ELSE
- IF ProductionDialog.IsOpen() == 0
- THEN
- SetState("Start_set_production")
- END
- END
-
- [STATE Verify_farm_production]
-
- // Is it eggs ?
- IF NextCommand.GetInternType() == 18 AND
- NextCommand.GetInternType2() == 0.50
- THEN
- NextCommand.Run()
- ClearCommandQueue()
- SetState("Wait_month_change")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("Start_set_production")
- END
-
-
- // ============================================================================
- // EXPLANATION : SHOP DIALOG
- // ============================================================================
- [STATE Wait_month_change]
- IF IsEnterState
- THEN
- Time.SetPace(10)
- END
-
- IF User.GetIncome() > 0
- THEN
- Time.SetPace(0.25)
- SetState("Start_explain_shop_dlg")
- END
-
- [STATE Start_explain_shop_dlg]
-
- FirstTutorialTextID = 243
- LastTutorialTextID = 245
- ReturnState = 'Wait_for_shop_dlg'
- SetState("Show_tutorial_text_serie")
-
- [STATE Wait_for_shop_dlg]
-
- IF ShopDialog.IsOpen() == 1
- THEN
- TutorialTextID = 248
- ReturnState = 'Wait_for_eggs'
- SetState("Show_tutorial_text")
- END
-
- [STATE Wait_for_eggs]
-
- IF ShopDialog.IsOpen() == 0
- THEN
- SetState("Start_explain_shop_dlg")
- END
-
- IF ShopDialog.GetProduct() == 18
- THEN
- FirstTutorialTextID = 251
- LastTutorialTextID = 252
- ReturnState = 'Wait_for_demand_supply'
- SetState("Show_tutorial_text_serie")
- END
-
- [STATE Wait_for_demand_supply]
-
- IF ShopDialog.IsOpen() == 0
- THEN
- SetState("Start_explain_shop_dlg")
- END
-
- IF ShopDialog.GetButtonPressed() == 2
- THEN
- SetState("Explain_mission_goal")
- END
-
- [STATE Wait_for_product_profit]
-
- IF ShopDialog.IsOpen() == 0
- THEN
- SetState("Start_explain_shop_dlg")
- END
-
- IF ShopDialog.GetProduct() <> 18
- THEN
- TutorialTextID = 231
- ReturnState = 'Wait_for_eggs'
- SetState("Show_tutorial_text")
- END
-
- IF ShopDialog.GetButtonPressed() == 1
- THEN
- TutorialTextID = 234
- ReturnState = 'Wait_for_product_sales'
- SetState("Show_tutorial_text")
- END
-
- [STATE Wait_for_product_sales]
-
- IF ShopDialog.IsOpen() == 0
- THEN
- SetState("Start_explain_shop_dlg")
- END
-
- IF ShopDialog.GetProduct() <> 18
- THEN
- TutorialTextID = 231
- ReturnState = 'Wait_for_eggs'
- SetState("Show_tutorial_text")
- END
-
- IF ShopDialog.GetButtonPressed() == 0
- THEN
- TutorialTextID = 235
- ReturnState = 'Go_back_to_demandsupply'
- SetState("Show_tutorial_text")
- END
-
- [STATE Go_back_to_demandsupply]
-
- IF ShopDialog.IsOpen() == 0
- THEN
- SetState("Start_explain_shop_dlg")
- END
-
- IF ShopDialog.GetProduct() <> 18
- THEN
- TutorialTextID = 231
- ReturnState = 'Wait_for_eggs'
- SetState("Show_tutorial_text")
- END
-
- IF ShopDialog.GetButtonPressed() == 2
- THEN
- TutorialTextID = 236
- ReturnState = 'Change_price_to_60'
- SetState("Show_tutorial_text")
- END
-
- [STATE Change_price_to_60]
-
- IF ShopDialog.IsOpen() == 0
- THEN
- SetState("Start_explain_shop_dlg")
- END
-
- IF ShopDialog.GetProduct() <> 18
- THEN
- TutorialTextID = 231
- ReturnState = 'Wait_for_eggs'
- SetState("Show_tutorial_text")
- END
-
- IF ShopDialog.GetPrice() == 0.60
- THEN
- TutorialTextID = 237
- ReturnState = 'Wait_for_dialog_accept'
- SetState("Show_tutorial_text")
- END
-
- [STATE Wait_for_dialog_accept]
-
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 33
- AND ChangeStore.GetPrice(18) == 0.60
- THEN
- NextCommand.Run()
- ClearCommandQueue()
- SetState("Wait_month_change_2")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("Start_explain_shop_dlg")
- END
- ELSE
- IF ShopDialog.IsOpen() == 0
- THEN
- SetState("Start_explain_shop_dlg")
- END
- END
-
- [STATE Wait_month_change_2]
- IF IsEnterState
- THEN
- temp = Time.Month
- Time.SetPace(10)
- END
-
- IF temp <> Time.Month
- THEN
- Time.SetPace(1)
- SetState("Start_explain_shop_dlg_2")
- END
-
- [STATE Start_explain_shop_dlg_2]
-
- TutorialTextID = 215
- ReturnState = 'Wait_for_shop_dlg_2'
- SetState("Show_tutorial_text")
-
- [STATE Wait_for_shop_dlg_2]
-
- IF ShopDialog.IsOpen() == 1
- THEN
- SetState("Explain_mission_goal")
- END
-
- [STATE Wait_for_product_profit_2]
-
- IF ShopDialog.IsOpen() == 0
- THEN
- SetState("Start_explain_shop_dlg_2")
- END
-
- IF ShopDialog.GetButtonPressed() == 1
- THEN
- TutorialTextID = 240
- ReturnState = 'Wait_for_product_sales_2'
- SetState("Show_tutorial_text")
- END
-
- [STATE Wait_for_product_sales_2]
-
- IF ShopDialog.IsOpen() == 0
- THEN
- SetState("Start_explain_shop_dlg_2")
- END
-
- IF ShopDialog.GetButtonPressed() == 0
- THEN
- TutorialTextID = 241
- ReturnState = 'Change_price_to_100'
- SetState("Show_tutorial_text")
- END
-
- [STATE Change_price_to_100]
-
- IF ShopDialog.IsOpen() == 0
- THEN
- SetState("Start_explain_shop_dlg_2")
- END
-
- IF ShopDialog.GetPrice() == 1.0
- THEN
- TutorialTextID = 242
- ReturnState = 'Wait_for_dialog_accept_2'
- SetState("Show_tutorial_text")
- END
-
- [STATE Wait_for_dialog_accept_2]
-
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 33
- THEN
- NextCommand.Run()
- ClearCommandQueue()
- SetState("Explain_mission_goal")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- TutorialTextID = 242
- ReturnState = 'Wait_for_dialog_accept_2'
- SetState("Show_tutorial_text")
- END
- ELSE
- IF ShopDialog.IsOpen() == 0
- THEN
- SetState("Start_explain_shop_dlg_2")
- END
- END
-
-
- // ============================================================================
- // EXPLANATION : MISSION GOAL
- // ============================================================================
-
- [STATE Explain_mission_goal]
- FirstTutorialTextID = 254
- LastTutorialTextID = 255
- ReturnState = 'End'
- SetState("Show_tutorial_text_serie")
-
-
-
- // ============================================================================
- // EXPLANATION : VCOND DIALOG
- // ============================================================================
- [STATE Explain_vcond]
- TutorialTextID = 252
- ReturnState = 'Wait_for_vcond_open'
- SetState("Show_tutorial_text")
-
- [STATE Wait_for_vcond_open]
- IF IsDialogOpen("UIF_missiongoal.uif") == 1
- THEN
- TutorialTextID = 253
- ReturnState = 'Wait_for_vcond_close'
- SetState("Show_tutorial_text")
- END
-
- [STATE Wait_for_vcond_close]
- IF IsDialogOpen("UIF_missiongoal.uif") == 0
- THEN
- TutorialTextID = 254
- ReturnState = 'End'
- SetState("Show_tutorial_text")
- END
-
- [STATE End]
-
- IF IsEnterState
- THEN
- StopCommandFiltering()
- END
-
- // Otherwise do nothing ...
-
-
-
-
- // ============================================================================
- // HELPER STATES
- //
- // Here are some states, which are used to do repetitive tasks.
- // ============================================================================
- //-----------------------------------------------------------------------------
- // Show_tutorial_text
- // - Opens tutorial text
- // - Waits until it is closed
- // - Returns to the return state
- // ----------------------------------------------------------------------------
- [STATE Show_tutorial_text]
-
- IF IsEnterState
- THEN
- TutorialText.Show(TutorialTextID)
- ELSE
- IF TutorialText.IsOpen() == 0
- THEN
- SetState(ReturnState)
- END
- END
-
- //-----------------------------------------------------------------------------
- // Show_tutorial_text_serie
- // - Shows a serie of tutorial texts from FirstTutorialTextID to LastTutorialTextID
- // ----------------------------------------------------------------------------
- [STATE Show_tutorial_text_serie]
-
- IF IsEnterState
- THEN
- Local_i = FirstTutorialTextID
- TutorialText.Show(FirstTutorialTextID)
- ELSE
- IF TutorialText.IsOpen() == 0
- THEN
- Local_i = Local_i + 1
-
- IF Local_i > LastTutorialTextID
- THEN
- SetState(ReturnState)
- ELSE
- TutorialText.Show(Local_i)
- END
- END
- END
-